from . import error
import traceback
from app.common import my_response
# from log import mylog


@error.app_errorhandler(404)
def page_not_found(e):
    print(e)
    return '404 error', 404


@error.app_errorhandler(Exception)
def internal_server_error(e):
    print('stack:\n%s' % traceback.format_exc())
    # mylog.error('stack:\n%s' % traceback.format_exc())
    if type(e) == KeyError:
        return my_response.fail('error param')
    else:
        return my_response.fail('system error:' + str(e))
